import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;


public class ThreadTCP extends Thread {
	private Environment _env;
	private Socket _socket;
	
	public ThreadTCP(Environment env, Socket connectionSocket){
		_env = env;
		_socket = connectionSocket;				
	}

	@Override
	public void run() {
		// datas' information
		int size = _env.get_size();
		int dataSize = 10*Environment.KB64;
		int i =0; 
		// network
		Socket socket = _socket;
		DataInputStream inFromClient;
		DataOutputStream outToClient;
		// datas
		byte tabReceive[] = new byte[size];
		byte tabSend[] = new byte[size];
		
		for (int j=0; j<size;j++){
			tabSend[j] = (byte) 41;
		}
		
		while(i<dataSize){
			try {
				inFromClient = new DataInputStream(socket.getInputStream());
				outToClient = new DataOutputStream(socket.getOutputStream());
				inFromClient.read(tabReceive);
				outToClient.write(tabSend, 0, size);
				outToClient.flush();
				i+= size;
				
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
